package com.kaibes.module.logger;

import java.time.LocalDateTime;
import java.util.List;

import com.kaibes.core.base.util.ObjectUtils;
import com.kaibes.orm.core.listener.InsertListener;
import com.kaibes.orm.curd.Insert;
import com.kaibes.orm.spring.OrmListener;

@OrmListener(service = ApiLogService.class)
public class ApiLogInsertListener implements InsertListener<Long> {

    @Override
    public void beforeInsert(Insert insert) throws Exception {
        List<Object> dataList = insert.getDatas();
        for (Object object : dataList) {
            ObjectUtils.setField(object, "createTime", LocalDateTime.now());
        }
    }
}
